﻿/*
 * Created by SharpDevelop.
 * User: fred
 * Date: 19/03/2011
 * Time: 20:38
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;

using GalaSoft.MvvmLight.Messaging;
using MetaVideoEditorEvolved.Messages;

namespace MetaVideoEditorEvolved
{
	/// <summary>
	/// Interaction logic for MultiAutoSearch.xaml
	/// </summary>
	public partial class MultiAutoSearch : Window
	{

		public MultiAutoSearch()
		{
			InitializeComponent();
			
			Messenger.Default.Register<CloseMessage>(this, (message) =>
			                                         {
			                                         	if (message.WindowToClose == WindowType.MultiAutoSearch)
			                                         	{
			                                         		this.Close();
			                                         	}
			                                         });
			
			Messenger.Default.Register<MediaItemChanged>(this, (message)=>
			                                             {
			                                             	ListBoxItem item = this.listBox.ItemContainerGenerator.ContainerFromItem(message.SearchItem) as ListBoxItem;
			                                             	
			                                             	if(item!=null)
			                                             	{
			                                             		this.listBox.ScrollIntoView(item);
			                                             		item.Focus();
			                                             	}
			                                             });

            this.Owner = System.Windows.Application.Current.MainWindow;
		}
	}
}